package com.yc.controller;


import com.yc.Result;
import com.yc.service.BloodSugarGluceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 血糖测量数据 前端控制器
 * </p>
 *
 * @author kuakha
 * @since 2021-04-07
 */
@RestController
@RequestMapping("/bloodSugarGluce")
@Api(value = "BloodSugarGluceController", tags = {"血糖数据管理"})
public class BloodSugarGluceController {

    @Autowired
    private BloodSugarGluceService bloodSugarGluceService;

    @ApiOperation(value = "APP用户血糖测量记录，折线图展示")
    @PostMapping("getGluceDataByType")
    public Result getGluceDataByType(@RequestParam(value = "type", required = false, defaultValue = "0") String type,
                                     String userId) {
        return bloodSugarGluceService.getGluceDataByType(userId,type);
    }

    @ApiOperation(value = "APP用户血糖测量记录，表格展示")
    @PostMapping("getGluceDataByDate")
    public Result getGluceDataByDate(String userId,@RequestParam(value = "dateType", required = false, defaultValue = "1") String dateType) {
        return bloodSugarGluceService.getGluceDataByDate(userId,dateType);
    }

    /**
     * 手动录入数据
     * @param userId
     * @param attr
     * @param sugarValue
     * @param examTime
     * @return
     */
    @ApiOperation(value = "APP手动添加用户测量血糖数据")
    @PostMapping("insertSugarDataByUser")
    public Result insertSugarDataByUser(String userId,String attr,String sugarValue,String examTime){
        return bloodSugarGluceService.insertSugarDataByUser(userId,attr,sugarValue,examTime);
    }
}